import 'package:flutter/material.dart';
class GradientPainter extends CustomPainter {
  const GradientPainter({required this.xS,required this.yS,required this.heightMul,required this.colorList,this.widthMul=1});
  final double xS;
  final double yS;
  final double heightMul;
  final double widthMul;
  final List<Color> colorList;
  @override
  void paint(Canvas canvas, Size size) {
    final rect = Rect.fromLTWH(xS, yS, size.width*widthMul, size.height * heightMul);
    final gradient = LinearGradient(
      begin: Alignment.topLeft,
      end: Alignment.bottomRight,
      colors: colorList,
    );
    final paint = Paint()..shader = gradient.createShader(rect);
    canvas.drawRect(rect, paint);
  }

  @override
  bool shouldRepaint(covariant CustomPainter oldDelegate) {
    return false;
  }
}